package com.danci.controller;


import com.danci.common.Result;
import com.danci.dto.UserDto;
import com.danci.dto.UserLoginDto;
import com.danci.dto.UserRequest;
import com.danci.service.IUserinfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author xxx
 * @since 2024-05-13
 */
@RestController
@RequestMapping("/userinfo")
@AllArgsConstructor
@Api("用户接口")
public class UserinfoController {

    private final IUserinfoService userinfoService;


    @ApiOperation("用户登录")
    @PostMapping("/login")
    public Result login(@RequestBody UserLoginDto userLoginDto) {
        return userinfoService.login(userLoginDto);
    }

    @ApiOperation("用户注册")
    @PostMapping("/register")
    public Result register(@RequestBody UserLoginDto userLoginDto) {
        return userinfoService.register(userLoginDto);
    }

    @ApiOperation("更新每日计划单词数")
    @PostMapping("/updatePlanDay")
    public Result updatePlanDay(@RequestBody UserRequest userRequest) {
        return userinfoService.updatePlanDay(userRequest);
    }
    @ApiOperation("更新所选词库")
    @PostMapping("/updateLid")
    private Result updateLid(@RequestBody UserRequest userRequest) {
        return userinfoService.updateLid(userRequest);
    }

    @ApiOperation("获取个人中心数据")
    @PostMapping("/getMyData")
    public Result getMyData(@RequestBody UserRequest userRequest) {
        return userinfoService.getMyData(userRequest);
    }

    @ApiOperation("更新用户信息")
    @PostMapping("/updateUserInfo")
    public Result updateUserInfo(@RequestBody UserDto userDto) {
        return userinfoService.updateUserInfo(userDto);
    }

    @ApiOperation("修改用户头像")
    @PostMapping("/updateAvatar")
    public Result updateAvatar(MultipartFile file, @RequestParam("userId")String userId) {
        return userinfoService.updateAvatar(file,userId);
    }
}
